using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PACKETPARSERMAX20.CORE
{
	public class battleground_template : MangosBase
	{
		public System.UInt32? id;
		public System.UInt16? minplayersperteam;
		public System.UInt16? maxplayersperteam;
		public System.UInt32? alliancestartloc;
		public System.Single? alliancestarto;
		public System.UInt32? hordestartloc;
		public System.Single? hordestarto;




		public override string GetInsertCommand()
		{
			return string.Format("INSERT IGNORE INTO `battleground_template` (`id`, `minplayersperteam`, `maxplayersperteam`, `alliancestartloc`, `alliancestarto`, `hordestartloc`, `hordestarto`) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}');", id.GetValueOrDefault(), minplayersperteam.GetValueOrDefault(), maxplayersperteam.GetValueOrDefault(), alliancestartloc.GetValueOrDefault(), alliancestarto.GetValueOrDefault(), hordestartloc.GetValueOrDefault(), hordestarto.GetValueOrDefault());
		}


		public override string GetUpdateCommand()
		{
            StringBuilder sb = new StringBuilder();
						sb.Append("UPDATE `battleground_template` SET ");
			if(minplayersperteam != null)
			{
				sb.AppendLine("`minplayersperteam`='" + minplayersperteam.Value.ToString() + "'");
			}
			if(maxplayersperteam != null)
			{
				sb.AppendLine("`maxplayersperteam`='" + maxplayersperteam.Value.ToString() + "'");
			}
			if(alliancestartloc != null)
			{
				sb.AppendLine("`alliancestartloc`='" + alliancestartloc.Value.ToString() + "'");
			}
			if(alliancestarto != null)
			{
				sb.AppendLine("`alliancestarto`='" + alliancestarto.Value.ToString() + "'");
			}
			if(hordestartloc != null)
			{
				sb.AppendLine("`hordestartloc`='" + hordestartloc.Value.ToString() + "'");
			}
			if(hordestarto != null)
			{
				sb.AppendLine("`hordestarto`='" + hordestarto.Value.ToString() + "'");
			}
				sb = sb.Replace("\r\n", ", ");
				sb.Append(" WHERE `id`='" + id.Value.ToString() + "';");
				sb = sb.Replace(",  WHERE", " WHERE");

            return sb.ToString();
		}


	}
}
